# -*- coding: utf-8 -*-
# @Time : 2018/12/24 14:09
# @Author : Administrator
# @File : read_data.py
# @Project : python_demo
# @title : read data
class Common():
    def read_data(self,filename):
        with open(filename) as f:
            content=f.readlines()
            key1=content[0].split(",")[0]
            key2 = content[0].split(",")[1]
            key3 = content[0].split(",")[2]
            key4 = content[0].split(",")[3].strip()

            list=[]
            for i in range(1,len(content)):
                # print(i)
                # print(content[i].split(","))
                dict={}
                dict[key1]=content[i].strip().split(",")[0]
                dict[key2] = content[i].strip().split(",")[1]
                dict[key3] = content[i].strip().split(",")[2]
                dict[key4] = content[i].strip().split(",")[3]
                list.append(dict)
            # print(list)
            return list

if __name__ == '__main__':
    Common().read_data("testdata.csv")
